import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;


public class TestDemo {

    public static void main(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(1);
        myArrayList.add(2);
        myArrayList.add(3);
        myArrayList.add(4);
        myArrayList.myToString();

        myArrayList.add(5,10);
        myArrayList.myToString();
        System.out.println(myArrayList.indexOf(1));
        System.out.println(myArrayList.contains(2));

    }

    public static void main2(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);

    }

    public static void main1(String[] args) {
    ArrayList<String> list = new ArrayList<>();
        list.add("Hello");
        list.add("world");
        list.add("beijing");

        for(String element:list){
        System.out.println(element.toString());
        }

        Iterator<String> iterator = list.listIterator();
        while (iterator.hasNext()) {
            System.out.print(iterator.next()+" -> ");
        }
        Iterator<String>iterable = (Iterator<String>) list.iterator();
        while(iterable.hasNext()) {
            String element = (String) iterable.next();
            System.out.println(element);
        }
    }
}
